$(document).ready(function(){
$(".submitbtn").click(function(){
		var div=$(this).parent().addClass("submitbtn");
		 var input1=div.find('input').val();
		 var input2=div.find('div').find('input').val();
		$("#adderss"+input1).css("display","block");
		var url="${pageContext.request.contextPath}/AddressController/getAddress.action";
		var val={"id":input2};
		$.post(url,val,function(data){
				var address=data.address;
				if(address==null){
			$("#adderss"+input1).html('<h4>获取地址信息失败<h4>');
				}else{
				var remarks=$("#remarks"+input2).html()
		$("#adderss"+input1).prepend(
		"<div id='spandiv"+input1+"'><span>联系人:"+address.name+"</span><br><span>电话:"+address.phonenum+"</span><br><span>地址:"+address.address+"</span><br><span>用户备注:"+remarks+"</span><br></div>"
	);
		}
		});
});	
$(".closebtn").toggle(function(){
	var id=$(this).find("input").val();
	$("#closediv"+id).css("display","block");
	/*
	$("#orderdiv"+id).css("display","none"); */
	
},function(){
var id=$(this).find("input").val();
	$("#closediv"+id).css("display","none");
});
$(".cancel").click(function(){
	var div=$(this).parent().addClass("closediv");
	div.css("display","none");
	
});
$(".confirm").click(function(){
	var div=$(this).parent().addClass("closediv");
	var id=div.find("input").val();
	var remarks=div.find("textarea").val();
	if(remarks==null||remarks==""){
	alert("取消原因不能为空");
	return false;
	}
	var url="${pageContext.request.contextPath}/OrderController/updateOrder.action";
	var val={"id":id,"state":4,"remarks":remarks};
	$.post(url,val,function(){
		
	});
	div.css("display","none");
	$("#orderdiv"+id).css("display","none");
	
});
$(".adderss").click(function(){
		
});
$(".confirmd").click(function(){
	var div=$(this).parent().addClass("address");
	var id=div.find("input").val();
	var url="${pageContext.request.contextPath}/OrderController/updateOrder.action";
	var val={"id":id,"state":2};
	$.post(url,val,function(){
	
	});
	var div=$(this).parent().addClass("submitbtn");
	div.css("display","none");
	$("#orderdiv"+id).css("display","none");
});
$(".closed").click(function(){
	var div=$(this).parent().addClass("adderssclass");
	div.css("display","none");
	var id=div.find("input").val();
	$("#spandiv"+id).remove();
});

});

